/**
 * the area of a triangle is a integer
 * the base of the triangle is a integer
 * the height of this triangle must be a integer
 */

#include <iostream>
#include <cmath>

using namespace std;

static bool perfect_square(int64_t n) {
    int64_t r = static_cast<int64_t>(sqrt(n));
    return r * r == n;
}

int main() {
    int64_t ans = 0;
    constexpr int64_t lim = 1'000'000'000 / 3;
    for (int64_t i = 3; i <= lim; i += 2) {
        if (perfect_square((i - 1) * (3 * i + 1))) {
            cout << i << ' ' << i << ' ' << i + 1 << endl;   
            ans += i + i + i + 1;
        }
        if (perfect_square((i + 1) * (3 * i - 1))) {
            cout << i << ' ' << i << ' ' << i - 1 << endl;   
            ans += i + i + i - 1;
        }
    }
    cout << ans << endl;
}